print("hello, world")
hello, world
%run zen.py
I can do this I will conqure the world I will make sure sunita will work as a nurse
This is a markdown cell.
import numpy as np
import scipy.integrate
import holoviews as hv
hv.extension("bokeh")
import bokeh.io
bokeh.io.output_notebook()
#generating data for plotting
x=np.linspace(0,2*np.pi,200)
#what does linspace do?===== returns evenly spaced number over the interval
y=np.exp(np.sin(np.sin(x)))
#plotting data
p=bokeh.plotting.figure(
frame_height=200,
frame_width=250,
x_axis_label='x',
y_axis_label='y',
x_range=[0,2*np.pi],
)
p.line(x,y,line_width=3)
bokeh.io.show(p)
#plottting using holoviews
hv.extension("bokeh")
hv.Curve(
(x, y),
kdims='x',
vdims='y'
).opts(
frame_height=200,
frame_width=250,
color="#1f0000",
padding=0.05,
show_grid=True,
xlim=(0, 2*np.pi),
)
# Make the HoloViews plot and render using hv render
hv_plot = hv.Curve(
(x, y),
kdims='x',
vdims='y'
).opts(
frame_height=200,
frame_width=250,
color="#1f77b4",
padding=0.05,
show_grid=True,
xlim=(0, 2*np.pi),
)
# Render with Bokeh and show
bokeh.io.show(hv.render(hv_plot))
#formatting a cells
def lorenz_attractor(r,t,p):
"""compute the right hand side of ODE for lorenz ataractor.
parameters:
------------
r: array_like, shape(3,)
(x,y,z) describes the position of the trajectory
t: dummy argument
dummy argument used as argument for
scipy.integrate.odeint
p: array_like, shape(3,)
Parameters (s,k,b) for the attractor.
returns:
---------
output: ndarray,shape(3,)
Time derivative of Lorenz attractor.
Notes
-----
.. Returns the right hand side of the system of ODEs describing
the Lorenz attractor.
x' = s * (y - x)
y' = x * (k - z) - y
z' = x * y - b * z
"""
#unpack variables:
x,y,z=r
s,p,b=p
return np.array([s * (y - x),
x * (p - z) - y,
x * y - b * z])
# Parameters to use
p = np.array([10.0, 28.0, 8.0 / 3.0])
# Initial condition
r0 = np.array([0.1, 0.0, 0.0])
# Time points to sample
t = np.linspace(0.0, 30.0, 4000)
# Use scipy.integrate.odeint to integrate Lorentz attractor
r = scipy.integrate.odeint(lorenz_attractor, r0, t, args=(p,))
print(r)
# Unpack results into x, y, z.
x, y, z = r.transpose()
[[ 1.00000000e-01 0.00000000e+00 0.00000000e+00] [ 9.35212863e-02 2.02130030e-02 7.28369200e-06] [ 8.89214596e-02 3.91201744e-02 2.72351925e-05] ... [-9.65419905e+00 -1.30767541e+01 2.37441986e+01] [-9.90889819e+00 -1.32724334e+01 2.42313722e+01] [-1.01582021e+01 -1.34365923e+01 2.47470002e+01]]
# Set up plot
p = bokeh.plotting.figure(
frame_height=200,
frame_width=200,
x_axis_label='x',
y_axis_label='z',
)
# Populate glyph
p.line(x, z)
bokeh.io.show(p)